/**
 * CustomerController
 *
 * @description :: Server-side logic for managing customers
 * @help        :: See http://sailsjs.org/#!/documentation/concepts/Controllers
 */

module.exports = {
	getCustomers: function (req, res) {
    Customer.find().then(function (record) {
      console.log('get all customers');
      res.send(record);
    })
  },

  getCustomer: function (req, res) {
    var id = req.params.id;
    Customer.find({id: id}).then(function (record) {
      console.log('get customer:', record);
      res.send(record);
    })
  },

  createCustomer: function (req, res) {
    var json = req.body;
    Customer.create(json).then(function (created) {
      console.log('create customer:', created);
      res.ok('ok');
    })
  },

  updateCustomer: function (req, res) {
    var id = req.params.id;
    var json = req.body;
    Customer.update({id: id}, json).then(function (updated) {
      console.log('update customer:', updated);
      res.ok('ok');
    })
  }
};

